package com.cloudwise.monitoring_system.service.mysqlService.impl;

import com.cloudwise.monitoring_system.entity.MonitorEvent;
import com.cloudwise.monitoring_system.dao.mysqlDao.MonitorEventDao;
import com.cloudwise.monitoring_system.service.mysqlService.MonitorEventService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (MonitorEvent)表服务实现类
 *
 * @author makejava
 * @since 2021-05-28 11:23:52
 */
@Service("monitorEventService")
public class MonitorEventServiceImpl implements MonitorEventService {
    @Resource
    private MonitorEventDao monitorEventDao;

    /**
     * 通过ID查询单条数据
     *
     * @param eventId 主键
     * @return 实例对象
     */
    @Override
    public MonitorEvent queryById(Integer eventId) {
        return this.monitorEventDao.queryById(eventId);
    }



    /**
     * 新增数据
     *
     * @param monitorEvent 实例对象
     * @return 实例对象
     */
    @Override
    public MonitorEvent insert(MonitorEvent monitorEvent) {
        this.monitorEventDao.insert(monitorEvent);
        return monitorEvent;
    }

    /**
     * 修改数据
     *
     * @param monitorEvent 实例对象
     * @return 实例对象
     */
    @Override
    public MonitorEvent update(MonitorEvent monitorEvent) {
        this.monitorEventDao.update(monitorEvent);
        return this.queryById(monitorEvent.getEventId());
    }

    /**
     * 通过主键删除数据
     *
     * @param eventId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer eventId) {
        return this.monitorEventDao.deleteById(eventId) > 0;
    }

    /**
     * 通过实体作为筛选条件分页查询
     *
     * @param monitorEvent 实例对象
     * @return 对象列表
     */
    @Override
    public List<MonitorEvent>  eventQueryAll( MonitorEvent monitorEvent) {
       return this.monitorEventDao.queryAll(monitorEvent);
    }
}
